package test;



import java.util.ArrayList;
import java.util.List;
import model.dao.NewsTypeDAO;
import model.entities.NewsType;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author THANMINH
 */
public class newtype {
    
    public static void main(String[] args) { 
             
        NewsTypeDAO newtype = new NewsTypeDAO();
        NewsType typenew = new NewsType();
        typenew.setIdNewType(5);
        typenew.setName("Van");
        typenew.setDescriptions("Toan");
        typenew.setIsActived(true);
        
        boolean abc =  newtype.editNewType(typenew);
        System.out.println(abc);
        List<NewsType> listnew = (List<NewsType>) newtype.GetAll();
        
        //NewType type = null;
        
        for(NewsType type : listnew ){
            System.out.println("Id : " + type.getIdNewType());
            System.out.println("Name : " + type.getName());
            System.out.println("Descriptions : " + type.getDescriptions());
            System.out.println("IsActived : " + type.isIsActived());
            System.out.println("-------------------------------------------");
        }
        
        
        
    }
    
    private void getAll(){
        NewsTypeDAO newtype = new NewsTypeDAO();
        
        List<NewsType> listnew = (List<NewsType>) newtype.GetAll();
        
        //NewType type = null;
        
        for(NewsType type : listnew ){
            System.out.println("Id : " + type.getIdNewType());
            System.out.println("Name : " + type.getName());
            System.out.println("Descriptions : " + type.getDescriptions());
            System.out.println("IsActived : " + type.isIsActived());
            System.out.println("-------------------------------------------");
        }
    }
    
    public void getById(int id){
        NewsTypeDAO dao = new NewsTypeDAO();
        NewsType type = dao.getById(id);
        System.out.println("Id : " + type.getIdNewType());
            System.out.println("Name : " + type.getName());
            System.out.println("Descriptions : " + type.getDescriptions());
            System.out.println("IsActived : " + type.isIsActived());
            System.out.println("-------------------------------------------");
    }
    
}
